import React, {Component} from "react";
import {View,Text, TouchableOpacity} from "react-native";


export default class RefreshPage extends Component {
    constructor(){
        super();
        this.state = {
            view: undefined,
            text: ""
        };
    }


    render(){
        return(
            <View>
                <Text>这是{this.state.text}</Text>
                <TouchableOpacity
                    activeOpacity={1}
                    onPress={this._click}>
                    <Text style={{backgroundColor:"#F00"}}>==========请点我=========</Text>
                </TouchableOpacity>
                {this.state.view}
                {this._getView2()}
                {this._getView()}
            </View>
        )
    }
    _getView=()=>{
        return <Text>这是{this.state.text}</Text>;
    }
    _getView2=()=>{
        return this.state.view;
    }
    _click=()=>{
        //这里只设置1次
        if(!this.state.view){
            this.state.view = <Text>这是{this.state.text}</Text>;
        }
        //改变数据
        this.setState({
            text:this.state.text+"+"
        })
    }

}